<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li,a{
            text-decoration: none;
            list-style: none;
            color: darkgrey;
      
            width: 360px;
            height: 70px;
            
        }
    </style>
    <script src="com.js"></script>
    <script>
        window.onload = function () {
            let userInfo = getCookie('userInfo') ? JSON.parse(getCookie('userInfo')) : null;
            if (userInfo) {
                document.querySelector('h1').innerHTML = `<h1>${userInfo.nickname}用户，欢迎</h1>`;
            } else {
                document.querySelector('h1').innerHTML = `<h1><a href="login.html">登录</a></h1>`;
            }
            ajax({
                url: 'http://phpclub.org.cn/edu/server/news.php',
                success: function (response) {
                    let html = '';
                    response.data.forEach(item => {
                        html += `<li><a href="content.html?id=${item.id}">${item.title}</a> </li>`;
                    })
                    document.querySelector('ul').innerHTML = html;
                }
            });

        }
    </script>
</head>

<body>
    <h1>XXX用户,欢迎您</h1>
    <ul></ul>
</body>

</html>